package Vistas;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JButton;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.border.BevelBorder;
import java.awt.Color;
import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseListener;

import javax.swing.UIManager;

import org.jvnet.substance.SubstanceLookAndFeel;
import javax.swing.SwingConstants;
import javax.swing.JTabbedPane;

import DAO.ModulosDAO;

import com.toedter.calendar.JCalendar;
import javax.swing.JLabel;
import javax.swing.JInternalFrame;
import java.awt.BorderLayout;
import java.beans.PropertyVetoException;
import javax.swing.border.TitledBorder;
import javax.swing.JSeparator;
import javax.swing.JDesktopPane;
import java.awt.Component;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class MenuPrincipal extends JFrame implements ActionListener, MouseListener {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	private JButton btnNotas;
	private JButton btnApuntes;
	private JButton btnFaltas;
	private JPanel panel_1;
	private JCheckBoxMenuItem chckbxmntmFaltas;
	private JCheckBoxMenuItem chckbxmntmApuntes;
	private JCheckBoxMenuItem chckbxmntmNotas;
	private JMenuItem mntmFaltas;
	private JMenuItem mntmNotas;
	private JMenuItem mntmApuntes;
	private JDesktopPane desktopPane;
	private int cont = 1;
	private JInternalFrame internalFrame = new JInternalFrame();
	private JTabbedPane tabbedPane;
	private JPanel panel2;
	private static JPopupMenu menu;
	private JMenuItem mntmEditarProfesor;
	private JMenuItem mntmEditarAlumno;
	private JMenuItem mntmCerrarUsuario;
	private JMenuItem mntmCerrarPrograma;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					JFrame.setDefaultLookAndFeelDecorated(true);
					SubstanceLookAndFeel
							.setSkin("org.jvnet.substance.skin.BusinessBlackSteelSkin");
					MenuPrincipal frame = new MenuPrincipal();

					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 * 
	 * @throws PropertyVetoException
	 */
	public MenuPrincipal() throws PropertyVetoException {

		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 834, 529);
		setExtendedState(MAXIMIZED_BOTH);

		JMenuBar menuBar = new JMenuBar();
		menuBar.setForeground(UIManager
				.getColor("CheckBoxMenuItem.selectionBackground"));
		menuBar.setBorder(new BevelBorder(BevelBorder.RAISED, Color.BLACK,
				Color.BLACK, SystemColor.textHighlight, UIManager
						.getColor("CheckBoxMenuItem.selectionBackground")));
		setJMenuBar(menuBar);

		JMenu mnAlumno = new JMenu("Alumno");
		mnAlumno.setBackground(Color.BLACK);
		menuBar.add(mnAlumno);

		mntmEditarAlumno = new JMenuItem("Editar Alumno");
		mntmEditarAlumno.setName("EditarAlumno");
		mnAlumno.add(mntmEditarAlumno);
		mntmEditarAlumno.addActionListener(this);

		JSeparator separator = new JSeparator();
		mnAlumno.add(separator);

		mntmApuntes = new JMenuItem("Apuntes");
		mntmApuntes.setName("mntmApuntes");
		mnAlumno.add(mntmApuntes);
		mntmApuntes.addActionListener(this);

		mntmFaltas = new JMenuItem("Faltas");
		mntmFaltas.setName("mntmFaltas");
		mnAlumno.add(mntmFaltas);
		mntmFaltas.addActionListener(this);

		mntmNotas = new JMenuItem("Notas");
		mntmNotas.setName("mntmNotas");
		mnAlumno.add(mntmNotas);
		mntmNotas.addActionListener(this);

		JMenu mnFavoritos = new JMenu("Favoritos");
		mnAlumno.add(mnFavoritos);

		chckbxmntmApuntes = new JCheckBoxMenuItem("Apuntes");
		chckbxmntmApuntes.setName("chckbxmntmApuntes");
		mnFavoritos.add(chckbxmntmApuntes);
		chckbxmntmApuntes.addActionListener(this);

		chckbxmntmFaltas = new JCheckBoxMenuItem("Faltas");
		chckbxmntmFaltas.setName("chckbxmntmFaltas");
		mnFavoritos.add(chckbxmntmFaltas);
		chckbxmntmFaltas.addActionListener(this);

		chckbxmntmNotas = new JCheckBoxMenuItem("Notas");
		chckbxmntmNotas.setName("chckbxmntmNotas");
		mnFavoritos.add(chckbxmntmNotas);

		JMenu mnProfesor = new JMenu("Profesor");
		menuBar.add(mnProfesor);

		mntmEditarProfesor = new JMenuItem("Editar Profesor");
		mnProfesor.add(mntmEditarProfesor);
		mntmEditarProfesor.setName("EditarProfesor");
		
		JMenu mnAplicacion = new JMenu("Aplicacion");
		menuBar.add(mnAplicacion);
		
		mntmCerrarUsuario = new JMenuItem("Cerrar Usuario");
		mnAplicacion.add(mntmCerrarUsuario);
		mntmCerrarUsuario.setName("CerrarUsuario");
		mntmCerrarUsuario.addActionListener(this);
		
		mntmCerrarPrograma = new JMenuItem("Cerrar Programa");
		mnAplicacion.add(mntmCerrarPrograma);
		mntmCerrarPrograma.setName("CerrarPrograma");
		mntmCerrarPrograma.addActionListener(this);
		
		
		mntmEditarProfesor.addActionListener(this);
		
		
		chckbxmntmNotas.addActionListener(this);

		JLabel lblTeHasRegistrado = new JLabel("Te has registrado como: "
				+ Acceso.user);

		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);

		JPanel panel = new JPanel();
		panel.setBorder(new TitledBorder(null, "Favoritos",
				TitledBorder.LEADING, TitledBorder.TOP, null, null));

		panel_1 = new JPanel();
		panel_1.setSize(MAXIMIZED_VERT, MAXIMIZED_HORIZ);

		GroupLayout gl_contentPane = new GroupLayout(contentPane);
		gl_contentPane.setHorizontalGroup(gl_contentPane
				.createParallelGroup(Alignment.LEADING)
				.addGroup(
						gl_contentPane
								.createSequentialGroup()
								.addComponent(panel, GroupLayout.DEFAULT_SIZE,
										95, Short.MAX_VALUE)
								.addPreferredGap(ComponentPlacement.RELATED)
								.addComponent(panel_1,
										GroupLayout.DEFAULT_SIZE, 1237,
										Short.MAX_VALUE))
				.addGroup(
						gl_contentPane
								.createSequentialGroup()
								.addComponent(lblTeHasRegistrado,
										GroupLayout.PREFERRED_SIZE, 213,
										GroupLayout.PREFERRED_SIZE)
								.addContainerGap(595, Short.MAX_VALUE)));
		gl_contentPane
				.setVerticalGroup(gl_contentPane
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								gl_contentPane
										.createSequentialGroup()
										.addGroup(
												gl_contentPane
														.createParallelGroup(
																Alignment.LEADING)
														.addGroup(
																gl_contentPane
																		.createSequentialGroup()
																		.addComponent(
																				panel,
																				GroupLayout.DEFAULT_SIZE,
																				431,
																				Short.MAX_VALUE)
																		.addGap(13))
														.addGroup(
																gl_contentPane
																		.createSequentialGroup()
																		.addComponent(
																				panel_1,
																				GroupLayout.PREFERRED_SIZE,
																				426,
																				Short.MAX_VALUE)
																		.addGap(18)))
										.addComponent(lblTeHasRegistrado)));

		desktopPane = new JDesktopPane();
		GroupLayout gl_panel_1 = new GroupLayout(panel_1);
		gl_panel_1.setHorizontalGroup(
			gl_panel_1.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_panel_1.createSequentialGroup()
					.addContainerGap()
					.addComponent(desktopPane, GroupLayout.DEFAULT_SIZE, 687, Short.MAX_VALUE)
					.addContainerGap())
		);
		gl_panel_1.setVerticalGroup(
			gl_panel_1.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_panel_1.createSequentialGroup()
					.addComponent(desktopPane, GroupLayout.DEFAULT_SIZE, 656, Short.MAX_VALUE)
					.addGap(5))
		);
		menu = new JPopupMenu();
		
		panel_1.add(desktopPane, BorderLayout.CENTER);
		internalFrame.setMaximizable(true);
		internalFrame.setSize(MAXIMIZED_HORIZ, MAXIMIZED_VERT);
		desktopPane.add(internalFrame);
		internalFrame.setBounds(0, 0, 668, 410);
		internalFrame.setVisible(true);

		tabbedPane = new JTabbedPane(JTabbedPane.TOP);
		internalFrame.getContentPane().add(tabbedPane, BorderLayout.CENTER);

		panel2 = new JPanel();
		tabbedPane.addTab("Horario", panel2);
		CargarDatos();

		JCalendar calendar = new JCalendar();
		tabbedPane.addTab("Calendario", null, calendar, null);

		panel_1.setLayout(gl_panel_1);

		btnNotas = new JButton("Notas");
		btnNotas.setVisible(false);
		btnNotas.setName("btnNotas");
		btnNotas.setHorizontalAlignment(SwingConstants.LEFT);
		btnNotas.addActionListener(this);

		btnApuntes = new JButton("Apuntes");
		btnApuntes.setVisible(false);
		btnApuntes.setName("btnApuntes");
		btnApuntes.setHorizontalAlignment(SwingConstants.LEFT);
		btnApuntes.addActionListener(this);

		btnFaltas = new JButton("Faltas");
		btnFaltas.setVisible(false);
		btnFaltas.setName("btnFaltas");
		btnFaltas.setHorizontalAlignment(SwingConstants.LEFT);
		btnFaltas.addActionListener(this);
		GroupLayout gl_panel = new GroupLayout(panel);
		gl_panel.setHorizontalGroup(gl_panel
				.createParallelGroup(Alignment.LEADING)
				.addGroup(
						gl_panel.createSequentialGroup()
								.addComponent(btnNotas,
										GroupLayout.DEFAULT_SIZE, 99,
										Short.MAX_VALUE).addContainerGap())
				.addGroup(
						Alignment.TRAILING,
						gl_panel.createSequentialGroup()
								.addGroup(
										gl_panel.createParallelGroup(
												Alignment.TRAILING)
												.addComponent(
														btnApuntes,
														Alignment.LEADING,
														GroupLayout.DEFAULT_SIZE,
														109, Short.MAX_VALUE)
												.addComponent(
														btnFaltas,
														GroupLayout.DEFAULT_SIZE,
														99, Short.MAX_VALUE))
								.addContainerGap()));
		gl_panel.setVerticalGroup(gl_panel.createParallelGroup(
				Alignment.LEADING).addGroup(
				gl_panel.createSequentialGroup().addComponent(btnApuntes)
						.addPreferredGap(ComponentPlacement.RELATED)
						.addComponent(btnFaltas)
						.addPreferredGap(ComponentPlacement.RELATED)
						.addComponent(btnNotas)
						.addContainerGap(327, Short.MAX_VALUE)));
		panel.setLayout(gl_panel);
		contentPane.setLayout(gl_contentPane);
		while (cont > 0) {
			if (Acceso.user.equals("cmartos")) {
				JOptionPane.showMessageDialog(contentPane, "Bienvenido "
						+ Acceso.user);
				cont--;
				break;
			}
			if (Acceso.user.equals("pbarea")) {
				JOptionPane.showMessageDialog(contentPane, "Bienvenido "
						+ Acceso.user);
				mntmEditarAlumno.setVisible(false);
				mntmEditarProfesor.setVisible(false);
				mntmEditarAlumno.setVisible(false);
				cont--;
				break;
			}
		}
	}

	private void CargarDatos() {

		JLabel label = new JLabel("10:00-10:50");

		JLabel label_1 = new JLabel("10:50-11:40");

		JLabel label_2 = new JLabel("11:40-12:30");

		JLabel label_3 = new JLabel("12:50-13:40");

		JLabel label_4 = new JLabel("13:40-14:30");

		JLabel lblLunes = new JLabel("Lunes");

		JButton btndam = new JButton("2DAM");
		btndam.setName("a");
		btndam.addMouseListener(this);

		JButton btndam_1 = new JButton("2DAM");
		btndam_1.setName("a");
		btndam_1.addMouseListener(this);

		JButton btndam_2 = new JButton("2DAM");
		btndam_2.setName("a");
		btndam_2.addMouseListener(this);

		JButton btnasir = new JButton("2ASIR");
		btnasir.setName("a");
		btnasir.addMouseListener(this);

		JButton btnasir_1 = new JButton("2ASIR");
		btnasir_1.setName("a");
		btnasir_1.addMouseListener(this);

		JSeparator separator_1 = new JSeparator();
		separator_1.setOrientation(SwingConstants.VERTICAL);

		JSeparator separator_2 = new JSeparator();

		JSeparator separator_3 = new JSeparator();

		JLabel label_5 = new JLabel("8:00-8:50");

		JLabel label_6 = new JLabel("8:50-9:40");

		JLabel label_7 = new JLabel("9:40-10:30");

		JLabel label_8 = new JLabel("11:00-11:50");

		JLabel label_9 = new JLabel("11:50-12:40");

		JLabel label_10 = new JLabel("12:50-13:40");

		JLabel label_11 = new JLabel("13:40-14:30");

		JButton btndam_3 = new JButton("2DAM");
		btndam_3.setName("a");
		btndam_3.addMouseListener(this);

		JButton btndam_4 = new JButton("2DAM");
		btndam_4.setName("a");
		btndam_4.addMouseListener(this);

		JButton btndam_5 = new JButton("2DAM");
		btndam_5.setName("a");
		btndam_5.addMouseListener(this);

		JButton btnsmr = new JButton("1SMR A");
		btnsmr.setName("a");
		btnsmr.addMouseListener(this);

		JButton btnsmr_1 = new JButton("1SMR A");
		btnsmr_1.setName("a");
		btnsmr_1.addMouseListener(this);

		JButton btnsmr_2 = new JButton("1SMR A");
		btnsmr_2.setName("a");
		btnsmr_2.addMouseListener(this);

		JSeparator separator_4 = new JSeparator();
		separator_4.setOrientation(SwingConstants.VERTICAL);

		JLabel lblMartes = new JLabel("Martes");

		JButton btnsmr_3 = new JButton("1SMR");
		btnsmr_3.setName("a");
		btnsmr_3.addMouseListener(this);

		JButton btnsmr_4 = new JButton("1SMR");
		btnsmr_4.setName("a");
		btnsmr_4.addMouseListener(this);

		JLabel lblMiercoles = new JLabel("Miercoles");

		JLabel lblJueves = new JLabel("Jueves");

		JLabel lblViernes = new JLabel("Viernes");

		JButton btnNewButton = new JButton("1SMR");
		btnNewButton.setName("a");
		btnNewButton.addMouseListener(this);

		JButton btnNewButton_1 = new JButton("Tutoria");
		btnNewButton_1.setName("a");
		btnNewButton_1.addMouseListener(this);

		JButton btnasir_2 = new JButton("2ASIR");
		btnasir_2.setName("a");
		btnasir_2.addMouseListener(this);

		JButton btnLibre = new JButton("Libre");
		btnLibre.setName("Libre");
		btnLibre.addMouseListener(this);

		JButton btnNewButton_2 = new JButton("Libre");
		btnNewButton_2.setName("a");
		btnNewButton_2.addMouseListener(this);

		JSeparator separator_5 = new JSeparator();
		separator_5.setOrientation(SwingConstants.VERTICAL);

		JButton btnLibre_1 = new JButton("Libre");
		btnLibre_1.setName("Libre");
		btnLibre_1.addMouseListener(this);

		JButton btnLibre_2 = new JButton("Libre");
		btnLibre_2.setName("Libre");
		btnLibre_2.addMouseListener(this);

		JButton btnsmrB = new JButton("1SMR B");
		btnsmrB.setName("a");
		btnsmrB.addMouseListener(this);

		JButton btnsmrb = new JButton("1SMR B");
		btnsmrb.setName("a");
		btnsmrb.addMouseListener(this);

		JButton btnsmrb_1 = new JButton("1SMR B");
		btnsmrb_1.setName("a");
		btnsmrb_1.addMouseListener(this);

		JSeparator separator_6 = new JSeparator();
		separator_6.setOrientation(SwingConstants.VERTICAL);

		JButton btnsmrC = new JButton("1SMR C");
		btnsmrC.setName("a");
		btnsmrC.addMouseListener(this);

		JButton btnsmrC_1 = new JButton("1SMR C");
		btnsmrC_1.setName("a");
		btnsmrC_1.addMouseListener(this);

		JButton btnsmrC_2 = new JButton("1SMR C");
		btnsmrC_2.setName("a");
		btnsmrC_2.addMouseListener(this);

		JButton btnLibre_3 = new JButton("Libre");
		btnLibre_3.setName("Libre");
		btnLibre_3.addMouseListener(this);

		JButton btnLibre_4 = new JButton("Libre");
		btnLibre_4.setName("Libre");
		btnLibre_4.addMouseListener(this);

		JButton btnLibre_5 = new JButton("Libre");
		btnLibre_5.setName("Libre");
		btnLibre_5.addMouseListener(this);
		GroupLayout gl_panel2 = new GroupLayout(panel2);
		gl_panel2
				.setHorizontalGroup(gl_panel2
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								gl_panel2
										.createSequentialGroup()
										.addGroup(
												gl_panel2
														.createParallelGroup(
																Alignment.LEADING)
														.addGroup(
																gl_panel2
																		.createSequentialGroup()
																		.addGap(23)
																		.addGroup(
																				gl_panel2
																						.createParallelGroup(
																								Alignment.LEADING)
																						.addGroup(
																								gl_panel2
																										.createSequentialGroup()
																										.addComponent(
																												label_4,
																												GroupLayout.DEFAULT_SIZE,
																												60,
																												Short.MAX_VALUE)
																										.addPreferredGap(
																												ComponentPlacement.RELATED)
																										.addComponent(
																												btnasir_1,
																												GroupLayout.DEFAULT_SIZE,
																												GroupLayout.DEFAULT_SIZE,
																												Short.MAX_VALUE)
																										.addGap(6))
																						.addGroup(
																								gl_panel2
																										.createSequentialGroup()
																										.addComponent(
																												label_3,
																												GroupLayout.DEFAULT_SIZE,
																												60,
																												Short.MAX_VALUE)
																										.addPreferredGap(
																												ComponentPlacement.RELATED)
																										.addComponent(
																												btnasir,
																												GroupLayout.DEFAULT_SIZE,
																												GroupLayout.DEFAULT_SIZE,
																												Short.MAX_VALUE)
																										.addGap(6))
																						.addGroup(
																								gl_panel2
																										.createSequentialGroup()
																										.addComponent(
																												label_2,
																												GroupLayout.DEFAULT_SIZE,
																												60,
																												Short.MAX_VALUE)
																										.addPreferredGap(
																												ComponentPlacement.RELATED)
																										.addComponent(
																												btndam_2,
																												GroupLayout.DEFAULT_SIZE,
																												GroupLayout.DEFAULT_SIZE,
																												Short.MAX_VALUE)
																										.addGap(8))
																						.addGroup(
																								gl_panel2
																										.createSequentialGroup()
																										.addComponent(
																												label_1,
																												GroupLayout.DEFAULT_SIZE,
																												60,
																												Short.MAX_VALUE)
																										.addPreferredGap(
																												ComponentPlacement.RELATED)
																										.addComponent(
																												btndam_1,
																												GroupLayout.DEFAULT_SIZE,
																												GroupLayout.DEFAULT_SIZE,
																												Short.MAX_VALUE)
																										.addGap(8))
																						.addGroup(
																								gl_panel2
																										.createSequentialGroup()
																										.addGroup(
																												gl_panel2
																														.createParallelGroup(
																																Alignment.TRAILING)
																														.addGroup(
																																gl_panel2
																																		.createSequentialGroup()
																																		.addGap(55)
																																		.addComponent(
																																				separator_2,
																																				GroupLayout.DEFAULT_SIZE,
																																				76,
																																				Short.MAX_VALUE))
																														.addGroup(
																																gl_panel2
																																		.createSequentialGroup()
																																		.addComponent(
																																				label,
																																				GroupLayout.PREFERRED_SIZE,
																																				57,
																																				Short.MAX_VALUE)
																																		.addPreferredGap(
																																				ComponentPlacement.RELATED)
																																		.addComponent(
																																				btndam,
																																				GroupLayout.DEFAULT_SIZE,
																																				64,
																																				Short.MAX_VALUE)))
																										.addGap(2))))
														.addGroup(
																gl_panel2
																		.createSequentialGroup()
																		.addGap(97)
																		.addComponent(
																				lblLunes)))
										.addGap(0)
										.addComponent(separator_1,
												GroupLayout.PREFERRED_SIZE, 10,
												GroupLayout.PREFERRED_SIZE)
										.addGroup(
												gl_panel2
														.createParallelGroup(
																Alignment.LEADING)
														.addGroup(
																gl_panel2
																		.createSequentialGroup()
																		.addGap(70)
																		.addComponent(
																				separator_3))
														.addGroup(
																gl_panel2
																		.createSequentialGroup()
																		.addGap(87)
																		.addComponent(
																				lblMartes,
																				GroupLayout.PREFERRED_SIZE,
																				42,
																				GroupLayout.PREFERRED_SIZE)
																		.addGap(29)
																		.addComponent(
																				lblMiercoles)
																		.addGap(48)
																		.addComponent(
																				lblJueves,
																				GroupLayout.PREFERRED_SIZE,
																				43,
																				GroupLayout.PREFERRED_SIZE)
																		.addGap(32)
																		.addComponent(
																				lblViernes))
														.addGroup(
																gl_panel2
																		.createSequentialGroup()
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addGroup(
																				gl_panel2
																						.createParallelGroup(
																								Alignment.LEADING)
																						.addGroup(
																								gl_panel2
																										.createSequentialGroup()
																										.addComponent(
																												label_8,
																												GroupLayout.DEFAULT_SIZE,
																												60,
																												Short.MAX_VALUE)
																										.addPreferredGap(
																												ComponentPlacement.RELATED)
																										.addComponent(
																												btnsmr,
																												GroupLayout.DEFAULT_SIZE,
																												GroupLayout.DEFAULT_SIZE,
																												Short.MAX_VALUE))
																						.addGroup(
																								gl_panel2
																										.createSequentialGroup()
																										.addComponent(
																												label_9,
																												GroupLayout.DEFAULT_SIZE,
																												60,
																												Short.MAX_VALUE)
																										.addPreferredGap(
																												ComponentPlacement.RELATED)
																										.addComponent(
																												btnsmr_1,
																												GroupLayout.DEFAULT_SIZE,
																												GroupLayout.DEFAULT_SIZE,
																												Short.MAX_VALUE))
																						.addGroup(
																								gl_panel2
																										.createSequentialGroup()
																										.addComponent(
																												label_7,
																												GroupLayout.DEFAULT_SIZE,
																												54,
																												Short.MAX_VALUE)
																										.addPreferredGap(
																												ComponentPlacement.UNRELATED)
																										.addComponent(
																												btndam_5,
																												GroupLayout.DEFAULT_SIZE,
																												69,
																												Short.MAX_VALUE))
																						.addGroup(
																								gl_panel2
																										.createSequentialGroup()
																										.addGroup(
																												gl_panel2
																														.createParallelGroup(
																																Alignment.LEADING)
																														.addComponent(
																																label_5,
																																GroupLayout.DEFAULT_SIZE,
																																GroupLayout.DEFAULT_SIZE,
																																Short.MAX_VALUE)
																														.addComponent(
																																label_6,
																																GroupLayout.DEFAULT_SIZE,
																																GroupLayout.DEFAULT_SIZE,
																																Short.MAX_VALUE))
																										.addGap(18)
																										.addGroup(
																												gl_panel2
																														.createParallelGroup(
																																Alignment.LEADING)
																														.addComponent(
																																btndam_3,
																																GroupLayout.DEFAULT_SIZE,
																																GroupLayout.DEFAULT_SIZE,
																																Short.MAX_VALUE)
																														.addComponent(
																																btndam_4,
																																GroupLayout.DEFAULT_SIZE,
																																67,
																																Short.MAX_VALUE)))
																						.addGroup(
																								gl_panel2
																										.createSequentialGroup()
																										.addComponent(
																												label_11,
																												GroupLayout.DEFAULT_SIZE,
																												GroupLayout.DEFAULT_SIZE,
																												Short.MAX_VALUE)
																										.addGap(73))
																						.addGroup(
																								gl_panel2
																										.createSequentialGroup()
																										.addComponent(
																												label_10,
																												GroupLayout.DEFAULT_SIZE,
																												60,
																												Short.MAX_VALUE)
																										.addPreferredGap(
																												ComponentPlacement.RELATED)
																										.addComponent(
																												btnsmr_2,
																												GroupLayout.DEFAULT_SIZE,
																												GroupLayout.DEFAULT_SIZE,
																												Short.MAX_VALUE)))
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addComponent(
																				separator_4,
																				GroupLayout.PREFERRED_SIZE,
																				GroupLayout.DEFAULT_SIZE,
																				GroupLayout.PREFERRED_SIZE)
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addGroup(
																				gl_panel2
																						.createParallelGroup(
																								Alignment.LEADING)
																						.addComponent(
																								btnNewButton,
																								GroupLayout.DEFAULT_SIZE,
																								GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								btnLibre,
																								GroupLayout.DEFAULT_SIZE,
																								GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								btnasir_2,
																								GroupLayout.DEFAULT_SIZE,
																								GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								btnsmr_4,
																								GroupLayout.DEFAULT_SIZE,
																								GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								btnsmr_3,
																								GroupLayout.DEFAULT_SIZE,
																								GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								btnNewButton_1,
																								GroupLayout.DEFAULT_SIZE,
																								GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE))
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addComponent(
																				separator_5,
																				GroupLayout.PREFERRED_SIZE,
																				4,
																				GroupLayout.PREFERRED_SIZE)
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addGroup(
																				gl_panel2
																						.createParallelGroup(
																								Alignment.LEADING)
																						.addComponent(
																								btnLibre_1,
																								GroupLayout.DEFAULT_SIZE,
																								GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								btnNewButton_2,
																								GroupLayout.DEFAULT_SIZE,
																								GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								btnLibre_2,
																								GroupLayout.DEFAULT_SIZE,
																								GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								btnsmrB,
																								GroupLayout.DEFAULT_SIZE,
																								GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								btnsmrb,
																								GroupLayout.DEFAULT_SIZE,
																								GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								btnsmrb_1,
																								GroupLayout.DEFAULT_SIZE,
																								GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE))
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addComponent(
																				separator_6,
																				GroupLayout.PREFERRED_SIZE,
																				GroupLayout.DEFAULT_SIZE,
																				GroupLayout.PREFERRED_SIZE)
																		.addPreferredGap(
																				ComponentPlacement.RELATED)
																		.addGroup(
																				gl_panel2
																						.createParallelGroup(
																								Alignment.LEADING)
																						.addComponent(
																								btnLibre_3,
																								GroupLayout.DEFAULT_SIZE,
																								GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								btnsmrC_2,
																								GroupLayout.DEFAULT_SIZE,
																								GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								btnsmrC_1,
																								GroupLayout.DEFAULT_SIZE,
																								GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								btnsmrC,
																								GroupLayout.DEFAULT_SIZE,
																								GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								btnLibre_4,
																								GroupLayout.DEFAULT_SIZE,
																								GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE)
																						.addComponent(
																								btnLibre_5,
																								GroupLayout.DEFAULT_SIZE,
																								GroupLayout.DEFAULT_SIZE,
																								Short.MAX_VALUE))))
										.addGap(95)));
		gl_panel2
				.setVerticalGroup(gl_panel2
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								gl_panel2
										.createSequentialGroup()
										.addGroup(
												gl_panel2
														.createParallelGroup(
																Alignment.LEADING)
														.addGroup(
																gl_panel2
																		.createSequentialGroup()
																		.addGap(56)
																		.addGroup(
																				gl_panel2
																						.createParallelGroup(
																								Alignment.LEADING)
																						.addComponent(
																								separator_1,
																								GroupLayout.PREFERRED_SIZE,
																								203,
																								GroupLayout.PREFERRED_SIZE)
																						.addGroup(
																								gl_panel2
																										.createSequentialGroup()
																										.addComponent(
																												lblLunes)
																										.addPreferredGap(
																												ComponentPlacement.RELATED)
																										.addComponent(
																												separator_2,
																												GroupLayout.PREFERRED_SIZE,
																												3,
																												GroupLayout.PREFERRED_SIZE)
																										.addGap(9)
																										.addGroup(
																												gl_panel2
																														.createParallelGroup(
																																Alignment.BASELINE)
																														.addComponent(
																																label)
																														.addComponent(
																																btndam,
																																GroupLayout.DEFAULT_SIZE,
																																GroupLayout.DEFAULT_SIZE,
																																Short.MAX_VALUE))
																										.addPreferredGap(
																												ComponentPlacement.UNRELATED)
																										.addGroup(
																												gl_panel2
																														.createParallelGroup(
																																Alignment.BASELINE)
																														.addComponent(
																																label_1)
																														.addComponent(
																																btndam_1))
																										.addPreferredGap(
																												ComponentPlacement.UNRELATED)
																										.addGroup(
																												gl_panel2
																														.createParallelGroup(
																																Alignment.BASELINE)
																														.addComponent(
																																label_2)
																														.addComponent(
																																btndam_2))
																										.addGap(18)
																										.addGroup(
																												gl_panel2
																														.createParallelGroup(
																																Alignment.BASELINE)
																														.addComponent(
																																label_3)
																														.addComponent(
																																btnasir))
																										.addPreferredGap(
																												ComponentPlacement.UNRELATED)
																										.addGroup(
																												gl_panel2
																														.createParallelGroup(
																																Alignment.BASELINE)
																														.addComponent(
																																label_4)
																														.addComponent(
																																btnasir_1))
																										.addGap(5)))
																		.addGap(62))
														.addGroup(
																gl_panel2
																		.createSequentialGroup()
																		.addGap(49)
																		.addGroup(
																				gl_panel2
																						.createParallelGroup(
																								Alignment.BASELINE)
																						.addComponent(
																								lblMartes)
																						.addComponent(
																								lblMiercoles)
																						.addComponent(
																								lblViernes)
																						.addComponent(
																								lblJueves))
																		.addPreferredGap(
																				ComponentPlacement.UNRELATED)
																		.addComponent(
																				separator_3,
																				GroupLayout.PREFERRED_SIZE,
																				5,
																				GroupLayout.PREFERRED_SIZE)
																		.addGap(12)
																		.addGroup(
																				gl_panel2
																						.createParallelGroup(
																								Alignment.LEADING)
																						.addComponent(
																								separator_6,
																								GroupLayout.DEFAULT_SIZE,
																								230,
																								Short.MAX_VALUE)
																						.addComponent(
																								separator_5,
																								GroupLayout.DEFAULT_SIZE,
																								230,
																								Short.MAX_VALUE)
																						.addGroup(
																								gl_panel2
																										.createSequentialGroup()
																										.addComponent(
																												btnsmrC)
																										.addPreferredGap(
																												ComponentPlacement.RELATED)
																										.addComponent(
																												btnsmrC_1)
																										.addGap(18)
																										.addComponent(
																												btnsmrC_2)
																										.addPreferredGap(
																												ComponentPlacement.UNRELATED)
																										.addComponent(
																												btnLibre_3)
																										.addPreferredGap(
																												ComponentPlacement.UNRELATED)
																										.addComponent(
																												btnLibre_4)
																										.addPreferredGap(
																												ComponentPlacement.RELATED)
																										.addComponent(
																												btnLibre_5))
																						.addGroup(
																								gl_panel2
																										.createSequentialGroup()
																										.addComponent(
																												btnNewButton_2)
																										.addGap(13)
																										.addComponent(
																												btnLibre_1)
																										.addPreferredGap(
																												ComponentPlacement.UNRELATED)
																										.addComponent(
																												btnLibre_2)
																										.addPreferredGap(
																												ComponentPlacement.UNRELATED)
																										.addComponent(
																												btnsmrB)
																										.addPreferredGap(
																												ComponentPlacement.UNRELATED)
																										.addComponent(
																												btnsmrb)
																										.addPreferredGap(
																												ComponentPlacement.RELATED)
																										.addComponent(
																												btnsmrb_1))
																						.addGroup(
																								gl_panel2
																										.createParallelGroup(
																												Alignment.LEADING,
																												false)
																										.addGroup(
																												gl_panel2
																														.createSequentialGroup()
																														.addGroup(
																																gl_panel2
																																		.createParallelGroup(
																																				Alignment.BASELINE)
																																		.addComponent(
																																				label_5)
																																		.addComponent(
																																				btndam_3))
																														.addPreferredGap(
																																ComponentPlacement.UNRELATED)
																														.addGroup(
																																gl_panel2
																																		.createParallelGroup(
																																				Alignment.BASELINE)
																																		.addComponent(
																																				label_6)
																																		.addComponent(
																																				btndam_4))
																														.addGap(13)
																														.addGroup(
																																gl_panel2
																																		.createParallelGroup(
																																				Alignment.BASELINE)
																																		.addComponent(
																																				label_7)
																																		.addComponent(
																																				btndam_5))
																														.addPreferredGap(
																																ComponentPlacement.UNRELATED)
																														.addGroup(
																																gl_panel2
																																		.createParallelGroup(
																																				Alignment.BASELINE)
																																		.addComponent(
																																				label_8)
																																		.addComponent(
																																				btnsmr))
																														.addPreferredGap(
																																ComponentPlacement.UNRELATED)
																														.addGroup(
																																gl_panel2
																																		.createParallelGroup(
																																				Alignment.BASELINE)
																																		.addComponent(
																																				label_9)
																																		.addComponent(
																																				btnsmr_1))
																														.addPreferredGap(
																																ComponentPlacement.UNRELATED)
																														.addGroup(
																																gl_panel2
																																		.createParallelGroup(
																																				Alignment.BASELINE)
																																		.addComponent(
																																				label_10)
																																		.addComponent(
																																				btnsmr_2))
																														.addGap(18)
																														.addComponent(
																																label_11))
																										.addComponent(
																												separator_4,
																												GroupLayout.DEFAULT_SIZE,
																												230,
																												Short.MAX_VALUE)
																										.addGroup(
																												gl_panel2
																														.createSequentialGroup()
																														.addComponent(
																																btnsmr_3)
																														.addPreferredGap(
																																ComponentPlacement.UNRELATED)
																														.addComponent(
																																btnsmr_4)
																														.addGap(13)
																														.addComponent(
																																btnNewButton)
																														.addPreferredGap(
																																ComponentPlacement.UNRELATED)
																														.addComponent(
																																btnNewButton_1)
																														.addPreferredGap(
																																ComponentPlacement.UNRELATED)
																														.addComponent(
																																btnasir_2)
																														.addPreferredGap(
																																ComponentPlacement.RELATED)
																														.addComponent(
																																btnLibre))))))
										.addGap(49)));		
		panel2.setLayout(gl_panel2);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		Acceso acceso = new Acceso();
		InsertarProfesor profesor = new InsertarProfesor();
		InsertarAlumno alumno =  new InsertarAlumno();
		Faltas faltas = new Faltas();
		faltas.setSize(panel2.getSize());
		Notas notas = new Notas();
		notas.setSize(panel2.getSize());
		VerApuntes apuntes = new VerApuntes();
		apuntes.setSize(panel2.getSize());
		
		if (e.getSource() instanceof JButton) {
			JButton boton2 = (JButton) e.getSource();
			if(boton2.getName().equals("a")){
				menu.setCursor(boton2.getCursor());
				menu.setVisible(true);
			}
			if(boton2.getName().equals("Libre")){
				menu.setCursor(boton2.getCursor());
				menu.remove(mntmFaltas);
				menu.remove(mntmNotas);
				menu.setVisible(true);
			}
			if (boton2.getName().equals("btnFaltas")) {
				desktopPane.remove(internalFrame);
				desktopPane.add(faltas);
				faltas.setVisible(true);
				panel_1.repaint();
				if (notas.isVisible()) {
					notas.dispose();
					panel_1.repaint();
				}
				if (apuntes.isVisible()) {
					apuntes.dispose();
					panel_1.repaint();
				}
			}
			if (boton2.getName().equals("btnNotas")) {
				desktopPane.remove(internalFrame);
				desktopPane.add(notas);
				notas.setVisible(true);
				panel_1.repaint();
				if (faltas.isVisible()) {
					faltas.dispose();
					panel_1.repaint();
				}
				if (apuntes.isVisible()) {
					apuntes.dispose();
					panel_1.repaint();
				}
			}
			if (boton2.getName().equals("btnApuntes")) {
				desktopPane.remove(internalFrame);
				desktopPane.add(apuntes);
				apuntes.setVisible(true);
				panel_1.repaint();
				if (faltas.isVisible()) {
					faltas.dispose();
					panel_1.repaint();
				}
				if (notas.isVisible()) {
					notas.dispose();
					panel_1.repaint();
				}
			}
		}
		if (e.getSource() instanceof JMenuItem) {
			JMenuItem boton = (JMenuItem) e.getSource();
			if(boton.getName().equals("CerrarUsuario")){
				acceso.setVisible(true);
				this.dispose();			
			}
			if(boton.getName().equals("CerrarPrograma")){
				System.exit(0);
			}
			if (boton.getName().equals("EditarProfesor")){
				desktopPane.remove(internalFrame);
				desktopPane.add(profesor);
				profesor.setVisible(true);
				panel_1.repaint();
			}
			if(boton.getName().equals("EditarAlumno")){
				desktopPane.remove(internalFrame);
				desktopPane.add(alumno);
				alumno.setVisible(true);
				panel_1.repaint();
			}
			if (boton.getName().equals("mntmFaltas")) {
				desktopPane.remove(internalFrame);
				desktopPane.add(faltas);
				faltas.setVisible(true);
				panel_1.repaint();
				if (notas.isVisible()) {
					notas.dispose();
					panel_1.repaint();
				}
				if (apuntes.isVisible()) {
					apuntes.dispose();
					panel_1.repaint();
				}
			}
			if (boton.getName().equals("mntmNotas")) {
				desktopPane.remove(internalFrame);
				notas.pack();
				desktopPane.add(notas);
				notas.setVisible(true);
				panel_1.repaint();
				if (faltas.isVisible()) {
					faltas.dispose();
					panel_1.repaint();
				}
				if (apuntes.isVisible()) {
					apuntes.dispose();
					panel_1.repaint();
				}
			}
			if (boton.getName().equals("mntmApuntes")) {
				desktopPane.remove(internalFrame);
				desktopPane.add(apuntes);
				apuntes.setVisible(true);
				panel_1.repaint();
				if (faltas.isVisible()) {
					faltas.dispose();
					panel_1.repaint();
				}
				if (notas.isVisible()) {
					notas.dispose();
					panel_1.repaint();
				}
			}
		}
		if (e.getSource() instanceof JCheckBoxMenuItem) {
			JCheckBoxMenuItem chek = (JCheckBoxMenuItem) e.getSource();
			if (chek.getName().equals("chckbxmntmFaltas")) {
				if (chckbxmntmFaltas.isSelected()) {
					btnFaltas.setVisible(true);
				} else {
					btnFaltas.setVisible(false);
				}
			}
			if (chek.getName().equals("chckbxmntmApuntes")) {
				if (chckbxmntmApuntes.isSelected()) {
					btnApuntes.setVisible(true);
				} else {
					btnApuntes.setVisible(false);
				}
			}
			if (chek.getName().equals("chckbxmntmNotas")) {
				if (chckbxmntmNotas.isSelected()) {
					btnNotas.setVisible(true);
				} else {
					btnNotas.setVisible(false);
				}
			}
		}
	}

	@Override
	public void mouseClicked(MouseEvent arg0) {
		// TODO Auto-generated method stub
		menu.add(mntmApuntes);
		menu.add(mntmFaltas);
		menu.add(mntmNotas);
		
		if(arg0.getComponent().getName().equals("Libre")){
			menu.remove(mntmFaltas);
			menu.remove(mntmNotas);
		}else if(menu.getComponentCount() < 2){
			    menu.add(mntmFaltas);
			    menu.add(mntmNotas);
		}
		if(menu.isVisible()){
			menu.setVisible(false);
		}else{
			menu.setLocation(arg0.getLocationOnScreen());
			menu.setVisible(true);
		}
		
		
	}

	@Override
	public void mouseEntered(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub
		menu.setVisible(false);
	}
}
